<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
  <!--<script src="http://{$Think.config.google_map_url}" async="async"></script>-->
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style>
    .layui-upload-img{
      width: 100px;
    }
  </style>
</head>
<body>
<div style="margin-top: 20px;">
</div>

<form class="layui-form" id="admin">
  <div class="layui-form-item">
    <label class="layui-form-label">行程名称</label>
    <div class="layui-input-inline" style="width: 500px">
      <input name="name"  lay-verify="required" value="{notempty name='$menu'}{$menu.name}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
  </div>
  {notempty name="$menu"}
  <input type="hidden" name="id" value="{$menu.id}">
  {/notempty}


  {notempty name="$use_type"}
  <input type="hidden" name="use_type" value="{$use_type}">
  {if $use_type==2}<!--定制行程-->
  <div class="layui-form-item">
    <label class="layui-form-label">起始出行日期</label>
    <div class="layui-input-inline" style="position: relative">
      <input name="start_go_time" id="start_go_time" value="{notempty name='$menu'}{$menu.sale_starttime}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
  </div>
  {/if}
  {/notempty}

  <div class="layui-form-item">
    <label class="layui-form-label">天数</label>
    <div class="layui-input-inline" style="position: relative">
      <input name="days"   {notempty name="$menu"} value="{$menu.days}"  readonly{/notempty} lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="number">
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">人数</label>
    <div class="layui-input-inline">
      <input name="people" lay-verify="required" value="{notempty name='$menu'}{$menu.people}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input" type="number">
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">产品编号</label>
    <div class="layui-input-inline">
      <input name="item_num" value="{notempty name='$menu'}{$menu.item_num}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
  </div>


  <div class="layui-form-item " >
    <label class="layui-form-label">供应商</label>
    <div class="layui-input-inline" style="width: 450px">
      <select  lay-filter="" id="supplier_id"  name="supplier_id"  lay-verify="required" lay-search>
        <option value="77777"  {notempty name='$menu'}{if $menu.supplier_id==''} selected{/if}{/notempty}>无</option>
        <option value="999999"  {notempty name='$menu'}{if $menu.supplier_id==999999} selected{/if}{/notempty}>自营</option>
        {volist name="supplier" id="vo"}
        <option value="{$vo.id}"  {notempty name='$menu'}{if $menu.supplier_id==$vo.id} selected{/if}{/notempty}>{$vo.name}</option>
        {/volist}
        <option value="1000000" {notempty name='$menu'}{if $menu.supplier_id==1000000} selected{/if}{/notempty}>其他</option>
      </select>
    </div>
    <div class="layui-input-inline" style="width:60px;">
      <button id="add_supplier_item_code" class="layui-btn layui-btn-radius layui-btn-primary layui-btn-small" style="width:50%;"><i class="layui-icon" style="margin-left: -9px;margin-top: -2px;"></i></button>
    </div>
  </div>



  <!--<div class="layui-form-item">-->
  <!--<label class="layui-form-label">供应商</label>-->
  <!--<div class="layui-input-inline">-->
  <!--<select id="city" lay-filter="city">-->
  <!--<option value="">请选择</option>-->
  <!--{volist name="city" id="vo"}-->
  <!--<option value="{$vo.id}" {notempty name='$menu.supplier_city'}{if $menu.supplier_city==$vo.id}selected{/if}{/notempty}>{$vo.name}</option>-->
  <!--{/volist}-->
  <!--</select>-->
  <!--</div>-->
  <!--<div class="layui-input-inline">-->
  <!--<input type="hidden" id="supplier_id" value="{notempty name='$menu'}{$menu.supplier}{/notempty}">-->
  <!--<select name="supplier" id="supplier" lay-filter="supplier">-->
  <!--<option value='0'>请选择</option>-->
  <!--</select>-->
  <!--</div>-->
  <!--<div class="layui-input-inline" style="width:60px;">-->
  <!--<button id="add_supplier_item_code" class="layui-btn layui-btn-radius layui-btn-primary layui-btn-small" style="width:50%;"><i class="layui-icon" style="margin-left: -9px;margin-top: -2px;"></i></button>-->
  <!--</div>-->
  <!--</div>-->


  <div class="layui-form-item layui-hide" id="supplier_item_code_div">
    <label class="layui-form-label">供应商<br/><span>(产品号)</span></label>
    <div class="layui-input-inline">
      <input name="supplier_item_code" id="supplier_item_code" value="{notempty name='$menu'}{$menu.supplier_item_code}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
  </div>



  <div class="layui-form-item">
    <label class="layui-form-label">平台产品名</label>
    <div class="layui-input-inline" style="width: 500px">
      <input name="product_name" value="{notempty name='$menu'}{$menu.product_name}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
  </div>




  <div class="layui-form-item">
    <label class="layui-form-label">预估价格（展示给客户）</label>
    <div class="layui-input-inline" style="width: 500px">
      <input name="budget_price" value="{notempty name='$menu'}{$menu.budget_price}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
  </div>



  <div class="layui-form-item">
    <label class="layui-form-label">售卖日期</label>
    <div class="layui-input-inline">
      <input name="sale_starttime" id="sale_starttime" value="{notempty name='$menu'}{$menu.sale_starttime}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
    <div class="layui-input-inline" style="width:20px;height:40px;margin-left: 7px;line-height: 40px">至</div>
    <div class="layui-input-inline">
      <input name="sale_endtime" id="sale_endtime"  value="{notempty name='$menu'}{$menu.sale_endtime}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input"  type="text">
    </div>
    <div class="layui-input-inline" style="width:60px;">
      <button id="add_saletime_more" class="layui-btn layui-btn-radius layui-btn-primary layui-btn-small" style="width:50%"><i class="layui-icon" style="margin-left: -8px;"></i></button>
    </div>
  </div>

  <div class="layui-form-item layui-form-text layui-hide" id="saletime_mone_div">
    <label class="layui-form-label">售卖日期<span>（补充）</span></label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea" id="saletime_more" name="saletime_more">{notempty name='$menu'}{$menu.saletime_more}{/notempty}</textarea>
    </div>
  </div>


  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">OTA售价（淡季）</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  name="ota_price_out">{notempty name='$menu'}{$menu.ota_price_out}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">OTA售价（旺季）</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  name="ota_price_busy">{notempty name='$menu'}{$menu.ota_price_busy}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">自有平台售价（淡季）</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  name="own_price_out">{notempty name='$menu'}{$menu.own_price_out}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">自有平台售价（旺季）</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  name="own_price_busy">{notempty name='$menu'}{$menu.own_price_busy}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label" style="text-align: center;">成本<br>（淡季）</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  name="cost_price_out">{notempty name='$menu'}{$menu.cost_price_out}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label" style="text-align: center;">成本<br>（旺季）</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  name="cost_price_busy">{notempty name='$menu'}{$menu.cost_price_busy}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">内部备注</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  name="description">{notempty name='$menu'}{$menu.description}{/notempty}</textarea>
    </div>
  </div>


  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">简介</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容"  class="layui-textarea" id="introduce" name="introduction">{notempty name='$menu'}{$menu.introduction}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">费用包含</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  id="introduce2" name="price">{notempty name='$menu'}{$menu.price}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">费用不含</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  id="introduce3" name="priceno">{notempty name='$menu'}{$menu.priceno}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">注意事项</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea" id="introduce4" name="careful">{notempty name='$menu'}{$menu.careful}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">退改规则</label>
    <div class="layui-input-block" style="max-width:500px;">
      <textarea placeholder="请输入内容" class="layui-textarea"  id="introduce5" name="back">{notempty name='$menu'}{$menu.back}{/notempty}</textarea>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">展示信息</label>
    <div class="layui-input-inline">
      <input type="checkbox" name="showintroduction" title="简介" {if $menu1.showintroduction!='0'}checked=""{/if}>
      <input type="checkbox" name="showprice" title="费用说明" {if $menu1.showprice!='0'}checked=""{/if}>
      <input type="checkbox" name="showcareful" title="注意事项" {if $menu1.showcareful!='0'}checked=""{/if}>
      <input type="checkbox" name="showback" title="退改规则" {if $menu1.showback!='0'}checked=""{/if}>
    </div>
  </div>


  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>

</form>


<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
  layui.use(['layer', 'form'], function() {
    var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form;
    $(window).on('load', function() {
      form.on('submit(admin)', function(data) {
        $.ajax({
          url:"{:url('admin/trip/addtrip')}",
          data:$('#admin').serialize(),
          type:'post',
          async: false,
          success:function(res) {
            layer.msg(res.msg);
            if(res.code == 1) {
              setTimeout(function(){
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
              },1500)
            }
          }
        })
        return false;
      });

      //编辑时显示选中供应商
      var city_id = $("#city").val();
      var supplier_id = $("#supplier_id").val();
      if(city_id > 0){
          $.post("{:url('admin/poi/getPoi')}",{id:city_id},function(data){
              if(data!=undefined&&data!=null&&data!=""){
                  var html="";
                  for(var i=0;i<data.length;i++){
                      if(supplier_id==data[i]["id"]){
                          html += "<option value="+data[i]["id"]+" selected>"+data[i]["name"]+"</option>";
                      }else{
                          html += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                      }
                  }
              }else{
                  html += "<option value='0'>请选择</option>";
              }
              $("#supplier").html(html);
              //重新渲染select
              form.render('select');
          },"Json");
      }

      //初始化编辑时，展开有内容的售卖时间补充字段
      var sale_time_more = $("#saletime_more").val();
      if(sale_time_more){
          $('#saletime_mone_div').removeClass('layui-hide');
      }
      //初始化编辑时，展开有内容的售卖时间补充字段
      var s_item_code = $("#supplier_item_code").val();
      if(s_item_code){
          $('#supplier_item_code_div').removeClass('layui-hide');
      }

    });
  });

  layui.use(['form','laydate'], function(){
      var  form = layui.form ;
      $ = layui.jquery ;
      laydate = layui.laydate;
      laydate.render({     //创建时间选择框
          elem: '#sale_starttime' //指定元素
          ,format: 'MM-dd'
      });
      laydate2 = layui.laydate;
      laydate2.render({     //创建时间选择框
          elem: '#sale_endtime' //指定元素
          ,format: 'MM-dd'
      });
      laydate3 = layui.laydate;
      laydate3.render({     //创建时间选择框
          elem: '#start_go_time' //指定元素
          ,format: 'yyyy-MM-dd'
      });
  });

  //服务商下拉
  layui.use(['layer', 'form'], function() {
      var form = layui.form;
      form.on('select(city)', function(param){
          var id = param.value;
          $.post("{:url('admin/poi/getPoi')}",{id:id},function(data){
              if(data!=undefined&&data!=null&&data!=""){
                  var html="";
                  for(var i=0;i<data.length;i++){
                      html += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                  }
              }else{
                  html += "<option value='0'>请选择</option>";
              }
              $("#supplier").html(html);
              //重新渲染select
              form.render('select');
          },"Json");
      });
  });


  //点击显示售卖时间补充字段
  layui.use('layer', function(){
      var $ = layui.jquery;
      var layer = layui.layer;
      $(document).on('click','#add_saletime_more',function(){
          if($('#saletime_mone_div').hasClass("layui-hide")){
              $('#saletime_mone_div').removeClass('layui-hide');
          }else{
              $('#saletime_mone_div').addClass('layui-hide');
          }
          return false;
      });

      $(document).on('click','#add_supplier_item_code',function(){
          if($('#supplier_item_code_div').hasClass("layui-hide")){
              $('#supplier_item_code_div').removeClass('layui-hide');
          }else{
              $('#supplier_item_code_div').addClass('layui-hide');
          }
          return false;
      });
  });



</script>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('introduce');
    var ue2 = UE.getEditor('introduce2');
    var ue3 = UE.getEditor('introduce3');
    var ue4 = UE.getEditor('introduce4');
    var ue5 = UE.getEditor('introduce5');
</script>
</body>
</html>
